package cn.village.service.impl;
import cn.village.dao.DataDictionaryMapper;
import cn.village.entity.DataDictionary;
import cn.village.service.DataDictionaryService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class DataDictionaryServiceImpl implements DataDictionaryService {

    @Resource
    private DataDictionaryMapper dataDictionaryMapper;

    public DataDictionary getDataDictionaryById(String id)throws Exception{
        return dataDictionaryMapper.getDataDictionaryById(id);
    }

    public List<DataDictionary>	getDataDictionaryListByMap(Map<String,Object> param)throws Exception{
        return dataDictionaryMapper.getDataDictionaryListByMap(param);
    }

    public Integer getDataDictionaryCountByMap(Map<String,Object> param)throws Exception{
        return dataDictionaryMapper.getDataDictionaryCountByMap(param);
    }

    public Integer qdtxAddDataDictionary(DataDictionary dataDictionary)throws Exception{
            //dataDictionary.setCreatedTime(new Date());
            return dataDictionaryMapper.insertDataDictionary(dataDictionary);
    }

    public Integer qdtxModifyDataDictionary(DataDictionary dataDictionary)throws Exception{
        //dataDictionary.setUpdatedTime(new Date());
        return dataDictionaryMapper.updateDataDictionary(dataDictionary);
    }

    public Integer qdtxDeleteDataDictionaryById(String id)throws Exception{
        return dataDictionaryMapper.deleteDataDictionaryById(id);
    }

    public Integer qdtxBatchDeleteDataDictionary(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return dataDictionaryMapper.batchDeleteDataDictionary(param);
    }


}
